<#include "/ftl/lib/operations.ftl"/>
<div class="easyui-layout" fit="true">  
	<div region="north" style="padding:5px;border:1px solid #ddd; background-color: #f4f4f4"  id="global_${action_id}" >
		<!-- <a href="javascript:;;" onclick="channel_add_${action_id}('${id?default('')}');" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">${action.getText('bg.datagrid.add')}</a> -->
	</div>  
	<div region="center" border="false">
		<div class="easyui-panel" data-options="href:'${request.contextPath}${namespace?default('')}/mp/product/brand-list.htm?action_id=${action_id}',fit:true">
		</div>
	</div>  
</div>

<script type="text/javascript">

function add_${action_id}(){
	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/product/brand-form.htm?action_id=${action_id}',
		width : 500,
		height : 400,
		modal : true,
		resizable:true,
		title : '${action.getText('bg.datagrid.add')}',
		buttons : [ {
			text : '${action.getText('bg.datagrid.add')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#form_${action_id}').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/product/brand-add.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						if(json.level!='error'){
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		}
	});	
}

function edit_${action_id}(data){
	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/product/brand-edit.htm?ajax=false&action_id=${action_id}&id='+data.id,
		width : 500,
		height : 500,
		modal : true,
		resizable:true,
		title : '${action.getText('bg.datagrid.edit')}',
		buttons : [ {
			text : '${action.getText('bg.datagrid.edit')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#form_${action_id}').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/product/brand-update.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						if(json.level!='error'){
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		}
	});
}

function delete_${action_id}(data) {
	$.messager.confirm('${action.getProperty('net.esj.background.message','bg.message.info')}', '${action.getText('bg.datagrid.delete.ask')}', function(b) {
		if (b) {
			$.ajax({
				url : '${request.contextPath}${namespace?default('')}/mp/product/brand-delete.json',
				data : {
					id : data.id
				},
				dataType : 'JSON',
				success : function(json) {
					$.messager.alert(json.title,json.msg,json.level);
					if(json.level!='error'){
						$("#datagrid_${action_id}").datagrid('reload');
					}
				}
			});
		}
	});
}

</script>
<@operations contextUri='mp/product/brand' />